package com.wen.mall.config;


import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

import java.util.ArrayList;

/**
 * Swagger配置类
 *
 * @author 温嘉璐
 * @date 2021/08/13
 */
@Configuration
@EnableSwagger2
public class SwaggerConfig {
    /**
     * 配置了Swagger的Docket的bean实例
     *
     * @return
     */
    @Bean
    public Docket docket() {

        return new Docket(DocumentationType.SWAGGER_2).apiInfo(apiInfo())
                .groupName("mall")
                .select()//通过select配置扫描接口
                // RequestHandlerSelectors配置扫描接口的方式
                .apis(RequestHandlerSelectors.basePackage("com.wen.mall.controller"))
                .build();

    }


    //配置文档Swagger信息
    private ApiInfo apiInfo() {
        //作者信息
        Contact contact = new Contact("温嘉璐", "http://www.wenjl.asia", "2021212321@qq.com");
        return new ApiInfo(
                "Mall接口文档",
                "钱途最重要",
                "v1.0",
                "www.baidu.com",
                contact,
                "Apache 2.0",
                "http://www.apache.org/licenses/LICENSE-2.0",
                new ArrayList()
        );
    }
}
